package com.erau.droidsatframework.core;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class LoggingOpenHelper extends SQLiteOpenHelper {

	//Database Stats
	private static final String DATABASE_NAME = "telemetry";
	private static final int DATABASE_VERSION = 1; 
	
	//Database Tables
	//ADC
	private static final String ADC_TABLE_CREATE = "create table ADC "
		+ "(_id integer primary key autoincrement, "
		+ "run_id integer not null, "
		+ "timestamp integer not null, "
		+ "dAngle REAL not null, "
		+ "Angle REAL not null, "
		+ "Velocity REAL not null);";
	
	//Power
	private static final String POWER_TABLE_CREATE = "create table Power "
		+ "(_id integer primary key autoincrement, "
		+ "run_id integer not null, "
		+ "timestamp integer not null, "
		+ "level integer not null, "
		+ "voltage integer not null, "
		+ "temperature integer not null);";
	
	//General Logging 
	private static final String GERNERAL_TABLE_CREATE = "create table General"
		+ "(_id integer primary key autoincrement, "
		+ "run_id integer not null, "
		+ "timestamp integer not null, "
		+ "tag text not null, "
		+ "msg text not null);";
		
	
	public LoggingOpenHelper(Context context){
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(ADC_TABLE_CREATE);
		db.execSQL(POWER_TABLE_CREATE);
		db.execSQL(GERNERAL_TABLE_CREATE);
		
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// as of now don't care
		
	}
	
}
